//
// Created by jsjxsy on 2022/8/18.
//

#include <iostream>

class A {
 public:
  A(int d) : _data(d) {}

  void show() const {
    std::cout << "data: " << _data << std::endl;
  }

 private:
  int _data;
};

int main(int, char **) {
  void (A::*ps)() const = &A::show; // 指向A类的show成员函数指针

  A a(3);
  (a.*ps)();  // 通过.*访问对象a的show成员函数

  A *pa = new A(4);
  (pa->*ps)(); // 通过->*访问pa指向对象的show成员函舒
  delete pa;

  return 0;
}